﻿@using System.Web.UI.WebControls
@using DevExpress.Web.ASPxGridView
@using DevExpress.Web.Mvc.UI
@using Dogshow.Model
@model IEnumerable<Korisnik>


@Html.DevExpress().GridView(s =>
{
    s.Name = "gvKorisnici";
    s.Caption = "Korisnici";
    s.CallbackRouteValues = new {Controller = "Korisnici", Action = "KorisniciGridViewCallback"};
    //s.Columns.Add(c => { });
    s.Columns.Add((c) =>
                      {
                          c.FieldName = "VrstaKorisnika";
                          c.Caption = "Vrsta";
                          c.Width = Unit.Pixel(20);
                          c.SetDataItemTemplateContent((t) =>
                                                           {
                                                               var id = (int) DataBinder.Eval(t.DataItem, "VrstaKorisnika");
                                                               ViewContext.Writer.WriteLine("<img style='float: left;' src='" + @Url.Content("~/Content/images/user" + id + ".png") + "' width=16 height=16 />");
                                                           });
                      });
    s.Columns.Add("KorisnickoIme", "Korisničko ime").Width = Unit.Pixel(80);
    s.Columns.Add("Naziv", "Naziv").Width = Unit.Pixel(150);
    s.SettingsBehavior.ConfirmDelete = true;
    s.SettingsText.ConfirmDelete = "Da li ste sigurni da želite da obrišete nalog?";
    s.SettingsText.EmptyDataRow = "Nema podataka";
    //s.SettingsBehavior.AllowGroup = true;
    //s.Settings.ShowGroupPanel = true;
    s.SettingsPager.Visible = true;
    s.SettingsPager.PageSize = 15;
    s.SettingsPager.NumericButtonCount = 5;
    s.Width = Unit.Pixel(350);
    s.SettingsBehavior.AllowFocusedRow = true;
    s.SettingsBehavior.AllowClientEventsOnLoad = false;
    s.Settings.ShowFilterRow = true;
    s.KeyFieldName = "KorisnickoIme";
    s.CommandColumn.Width = Unit.Pixel(35);
    s.CommandColumn.Visible = true;
    s.CommandColumn.DeleteButton.Visible = true;
    s.CommandColumn.ButtonType = ButtonType.Image;
    s.CommandColumn.DeleteButton.Image.ToolTip = "Obriši";
    s.CommandColumn.DeleteButton.Image.Url = @Url.Content("~/Content/images/user_trash.png");
    s.SettingsEditing.DeleteRowRouteValues = new {Controller = "Korisnici", Action = "ObrisiKorisnika"};
    var editBtn = new GridViewCommandColumnCustomButton();
    editBtn.Image.Url = @Url.Content("~/Content/images/edit.png");
    editBtn.Image.ToolTip = "Izmeni";
    s.CommandColumn.CustomButtons.Add(editBtn);
    s.ClientSideEvents.CustomButtonClick = "onEditButtonClick";


}).Bind(Model).GetHtml()
      